<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  function fib(n) {
    if (n <= 1) {
      return n = 1;
    }
    return fib(n - 1) + fib(n - 2);
  }
  var b = fib(6);
  console.log(b)



  function rabbit(n) {
    if (n <= 2) {
      return 1;
    }
    var a = 1,
      b = 1,
      r = 0;
    for (var i = 3; i <= n; i++) {
      r = a + b;
      a = b;
      b = r;
      console.log("第 " + i + " 项的值： " + r);
    }
    return r;
  }


  /**
   *这是最简单的代码  ---递归的方法 
   * 
  */
   function digui(n) {
   return n <= 2 ? 1 : digui(n - 1) + digui(n - 2);
   }
   
  console.log(rabbit(10));
  console.log(digui(13));
</script>

</html>